App({
  onLaunch: function (options) {
    this.checkForUpdates()
    const user = wx.getStorageSync('user')
        if (user.length != 0) {
          wx.switchTab({
            url: '/pages/workbench/workbench',
          })
        }else{
          wx.redirectTo({
            url: '/pages/my/login/login',
          })
        }
  },
  checkForUpdates: function () {
    var e = wx.getUpdateManager();
    console.log(e)
    e.onCheckForUpdate((function (e) {
        console.log(e.hasUpdate)
      })),
      e.onUpdateReady((function () {
        wx.showModal({
          title: "更新提示",
          content: "新版本已经准备好，是否重启应用？",
          success: function (n) {
            n.confirm && e.applyUpdate()
          }
        })
      })),
      e.onUpdateFailed((function () {
        wx.showModal({
          title: "已有新版本",
          content: "请您删除当前小程序，到微信 “发现-小程序” 页，重新搜索打开",
          showCancel: !1
        })
      }))
  }
});